<script language="VB" runat="server">
    Public PercentComplete As Single
    Public Style As String = "IE"
    Public Width As Short = 150

    Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)
        
        If Not Page.IsPostBack Then
            Dim strProgressBarHtml As String

            strProgressBarHtml = BuildProgressBarChunked(PercentComplete, Width)
		
            litProgressBar.Text = strProgressBarHtml
        End If       
    
    End Sub
    

	Function BuildProgressBarHtmlTable(sglPercentComplete As Single, intWidth As Integer) As String
		Dim intBarLength  As Short
		Dim sbDisplayHtml As New StringBuilder

		If 0 <= sglPercentComplete And sglPercentComplete <= 100 Then
			' Compensate for the width of the table border
			intBarLength = intWidth - 4

			sbDisplayHtml.Append("<table border=""1"" cellspacing=""0"" cellpadding=""0""><tr><td>")
			sbDisplayHtml.Append("<table width=""" & intBarLength & """ border=""0"" cellspacing=""0"" cellpadding=""0"">")
			sbDisplayHtml.Append("<tr><td width=""" & System.Math.Round(sglPercentComplete * intBarLength / 100) & """ style=""background-color:#0000FF"">&nbsp;</td><td>&nbsp;</td></tr>")
			sbDisplayHtml.Append("</table>")
			sbDisplayHtml.Append("</td></tr></table>")
		End If

		BuildProgressBarHtmlTable = sbDisplayHtml.ToString()
	End Function

    Function BuildProgressBarChunked(ByVal sglPercentComplete As Single, ByVal intWidth As Integer) As String
        Dim strImageBaseName As String

        Dim intImageHeight As Short
        Dim intImageLeftWidth As Short
        Dim intImageRightWidth As Short
        Dim intImageChunkWidth As Short

        Dim intChunksTotal As Short
        Dim intChunksFilled As Short
        Dim I As Short

        Dim sbDisplayHtml As New StringBuilder

	
        strImageBaseName = "../../Interfaz/Otros/Controles/images/progress_ie_"
        intImageHeight = 17
        intImageLeftWidth = 4
        intImageRightWidth = 4
        intImageChunkWidth = 8

        intChunksTotal = (intWidth - (intImageLeftWidth + intImageRightWidth)) \ intImageChunkWidth

        If 0 <= sglPercentComplete And sglPercentComplete <= 100 Then
            intChunksFilled = System.Math.Round(sglPercentComplete * intChunksTotal / 100)

            sbDisplayHtml.Append("<img src=""" & strImageBaseName & "left.gif"" border=""0"" height=""" & intImageHeight & """ width=""" & intImageLeftWidth & """>")
            For I = 1 To intChunksTotal
                If I <= intChunksFilled Then
                    sbDisplayHtml.Append("<img src=""" & strImageBaseName & "full.gif""  border=""0"" height=""" & intImageHeight & """ width=""" & intImageChunkWidth & """ alt=""" & sglPercentComplete & "%"">")
                Else
                    sbDisplayHtml.Append("<img src=""" & strImageBaseName & "empty.gif"" border=""0"" height=""" & intImageHeight & """ width=""" & intImageChunkWidth & """ alt=""" & (100 - sglPercentComplete) & "%"">")
                End If
            Next
            sbDisplayHtml.Append("<img src=""" & strImageBaseName & "right.gif"" border=""0"" height=""" & intImageHeight & """ width=""" & intImageRightWidth & """>")
        End If
        BuildProgressBarChunked = sbDisplayHtml.ToString()
    End Function
</script>
<asp:Literal id="litProgressBar" runat="server" />